package com.gitee.sdlszjb.response;


import com.fasterxml.jackson.annotation.JsonInclude;

/**
 * 文件描述
 *
 * @author 庄壮壮
 * @since 2021-01-09 13:40
 */
@JsonInclude(JsonInclude.Include.NON_NULL)
public class AniviaPagination extends AniviaResponse {
    private int current;
    private int pageSize;
    private long total;

    public static AniviaPagination success(AniviaPageResult<?> pageResult) {
        AniviaPagination antdPagination = new AniviaPagination();
        if (pageResult == null)
            return antdPagination;
        antdPagination.setSuccess(true);
        antdPagination.setErrorCode(0);
        antdPagination.setData(pageResult.getData());
        antdPagination.setPageSize(pageResult.getPageSize());
        antdPagination.setCurrent(pageResult.getCurrent());
        antdPagination.setTotal(pageResult.getTotal());
        return antdPagination;
    }

    public static AniviaResponse error(int code, String message) {
        AniviaPagination antdPagination = new AniviaPagination();
        antdPagination.setErrorCode(code);
        antdPagination.setErrorMessage(message);
        return antdPagination;
    }

    public static AniviaResponse error(String message) {
        return error(400, message);
    }


    public int getCurrent() {
        return current;
    }

    public void setCurrent(int current) {
        this.current = current;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public long getTotal() {
        return total;
    }

    public void setTotal(long total) {
        this.total = total;
    }
}
